//
//  BCApplicationInfomationCell.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2019/1/16.
//  Copyright © 2019 guoshikeji. All rights reserved.
//

#import "BCApplicationInfomationCell.h"

@implementation BCApplicationInfomationCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupApplicationInfomationCellSubviews];
    }
    return self;
}

- (QMUILabel *)detailsLabel {
    if (!_detailsLabel) {
        _detailsLabel = [QMUILabel new];
        _detailsLabel.textColor = [UIColor qmui_colorWithHexString:@"#AEAEAE"];
        _detailsLabel.textAlignment = NSTextAlignmentRight;
        _detailsLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
        _detailsLabel.adjustsFontSizeToFitWidth = true;
        _detailsLabel.numberOfLines = 2;
        [self.contentView addSubview:_detailsLabel];
        [_detailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView).offset(-15.0);
            make.centerY.mas_equalTo(self.contentView);
            make.left.mas_equalTo(self.titleLabel.mas_right).offset(5.0);
        }];
    }
    return _detailsLabel;
}

- (void)setupApplicationInfomationCellSubviews {
    self.titleLabel = [QMUILabel new];
    self.titleLabel.textColor = [UIColor qmui_colorWithHexString:@"#333333"];
    self.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
    self.titleLabel.adjustsFontSizeToFitWidth = true;
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.left.mas_equalTo(self.contentView).offset(15.0);
        make.width.mas_lessThanOrEqualTo(self.contentView).multipliedBy(.5).offset(-15.0);
    }];
}


- (void)setCellModel:(BCApplicationInfoCellModel *)cellModel {
    [super setCellModel:cellModel];
    //
    self.titleLabel.text = BCLocalizedKey(cellModel.titleKey);
    [self.titleLabel sizeToFit];
    //
    self.detailsLabel.text = cellModel.detailsContent;
}


@end
